package com.kangfu.api.service.impl;

import com.kangfu.api.service.INoticeService;
import com.kangfu.db.mapper.NoticeMapper;
import com.kangfu.db.model.vo.NoticeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl implements INoticeService {

    @Autowired
    public NoticeMapper noticeMapper;

    @Override
    public List<NoticeVo> selectNoticeByUserId(int userId, int page) {
        if (page <= 1) {
            page = 1;
        }
        int pageSize = 20;
        int offset = (page - 1)*pageSize;
        return noticeMapper.selectNoticeByUserId(userId, offset, pageSize);
    }


    @Override
    public int updateNoticeReadFlag(int userId, int id) {
        return noticeMapper.updateNoticeReadFlag(userId, id);
    }


    @Override
    public int updateAllNoticeReadFlag(int userId) {
        return noticeMapper.updateAllNoticeReadFlag(userId);
    }
}
